qt5 窗口启动居中显示 |
您所在的位置:网站首页 › qt 窗体居中 › qt5 窗口启动居中显示 |
main.cpp里面修改 #include "mainwindow.h" #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; //w.show(); //移动窗体到屏幕中央 QRect rect = w.frameGeometry(); QDesktopWidget desktop; QPoint centerPoint = desktop.availableGeometry().center(); rect.moveCenter(centerPoint); w.move(rect.topLeft()); w.show(); return a.exec(); }qt6.0 //移动窗体到屏幕中央 QRect rect = w.frameGeometry(); // QDesktopWidget desktop; QScreen* screen = QGuiApplication::primaryScreen(); QPoint centerPoint = screen->availableGeometry().center(); rect.moveCenter(centerPoint); w.move(rect.topLeft()); w.show();
翻译 搜索 复制 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |